home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / ewl / examples / ewl_paned_test.c < prev    next >
C/C++ Source or Header  |  2006-01-09  |  6KB  |  178 lines

  1. #include "ewl_test.h"
  2.  
  3. static Ewl_Widget *paned_button;
  4.  
  5. static void
  6. ewl_paned_test_cb_clicked(Ewl_Widget *w, void *ev __UNUSED__,
  7.                             void *data)
  8. {
  9.     printf("Clicked %s\n", (char *)data);
  10.  
  11.     ewl_widget_hide(w);
  12. }
  13.  
  14. static void
  15. ewl_paned_test_cb_clicked_destroy(Ewl_Widget *w, void *ev __UNUSED__,
  16.                             void *data)
  17. {
  18.     printf("Destroy Clicked %s\n", (char *)data);
  19.  
  20.     ewl_widget_destroy(w);
  21. }
  22.  
  23. static void
  24. __destroy_paned_test_window(Ewl_Widget * w, void *ev_data __UNUSED__,
  25.                         void *user_data __UNUSED__)
  26. {
  27.     ewl_widget_destroy(w);
  28.     ewl_callback_append(paned_button, EWL_CALLBACK_CLICKED,
  29.                 __create_paned_test_window, NULL);
  30. }
  31.  
  32. static void
  33. ewl_paned_test_cb_add(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__,
  34.                                 void *data)
  35. {
  36.     Ewl_Widget *o;
  37.     Ewl_Paned *p;
  38.  
  39.     p = data;
  40.  
  41.     o = ewl_button_new();
  42.     ewl_button_label_set(EWL_BUTTON(o), "New Button");
  43.     ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_SHRINK);
  44.     ewl_container_child_append(EWL_CONTAINER(p), o);
  45.     ewl_callback_append(o, EWL_CALLBACK_CLICKED,
  46.             ewl_paned_test_cb_clicked_destroy, "New Button");
  47.     ewl_widget_show(o);
  48. }
  49.  
  50. void
  51. __create_paned_test_window(Ewl_Widget * w, void *ev_data __UNUSED__,
  52.                         void *user_data __UNUSED__)
  53. {
  54.     Ewl_Widget *paned_win, *box, *pane1, *pane2, *pane3, *o;
  55.  
  56.     paned_button = w;
  57.  
  58.     paned_win = ewl_window_new();
  59.     ewl_window_title_set(EWL_WINDOW(paned_win), "Paned Test");
  60.     ewl_window_name_set(EWL_WINDOW(paned_win), "EWL Test Application");
  61.     ewl_window_class_set(EWL_WINDOW(paned_win), "EFL Test Application");
  62.     ewl_object_size_request(EWL_OBJECT(paned_win), 400, 600);
  63.  
  64.     if (w) {
  65.         ewl_callback_del(w, EWL_CALLBACK_CLICKED, 
  66.                     __create_paned_test_window);
  67.         ewl_callback_append(paned_win, EWL_CALLBACK_DELETE_WINDOW,
  68.                     __destroy_paned_test_window, NULL);
  69.     } else
  70.         ewl_callback_append(paned_win, EWL_CALLBACK_DELETE_WINDOW,
  71.                     __close_main_window, NULL);
  72.     ewl_widget_show(paned_win);
  73.  
  74.     /*
  75.      * Create the main box for holding the widgets
  76.      */
  77.     box = ewl_vbox_new();
  78.     ewl_container_child_append(EWL_CONTAINER(paned_win), box);
  79.     ewl_widget_show(box);
  80.  
  81.     pane1 = ewl_vpaned_new();
  82.     ewl_container_child_append(EWL_CONTAINER(box), pane1);
  83.     ewl_widget_show(pane1);
  84.  
  85.     pane2 = ewl_hpaned_new();
  86.     ewl_container_child_append(EWL_CONTAINER(pane1), pane2);
  87.     ewl_widget_show(pane2);
  88.  
  89.     o = ewl_button_new();
  90.     ewl_button_label_set(EWL_BUTTON(o), "Fill");
  91.     ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_FILL);
  92.     ewl_container_child_append(EWL_CONTAINER(pane2), o);
  93.     ewl_callback_append(o, EWL_CALLBACK_CLICKED,
  94.             ewl_paned_test_cb_clicked, "Fill");
  95.     ewl_widget_show(o);
  96.  
  97.     o = ewl_button_new();
  98.     ewl_button_label_set(EWL_BUTTON(o), "HFill | VShrink");
  99.     ewl_object_fill_policy_set(EWL_OBJECT(o), 
  100.             EWL_FLAG_FILL_HFILL | EWL_FLAG_FILL_VSHRINK);
  101.     ewl_container_child_append(EWL_CONTAINER(pane2), o);
  102.     ewl_callback_append(o, EWL_CALLBACK_CLICKED,
  103.             ewl_paned_test_cb_clicked, "HFill | VShrink");
  104.     ewl_widget_show(o);
  105.  
  106.     o = ewl_button_new();
  107.     ewl_button_label_set(EWL_BUTTON(o), "HShrink | VFill");
  108.     ewl_object_fill_policy_set(EWL_OBJECT(o), 
  109.             EWL_FLAG_FILL_HSHRINK | EWL_FLAG_FILL_VFILL);
  110.     ewl_container_child_append(EWL_CONTAINER(pane2), o);
  111.     ewl_callback_append(o, EWL_CALLBACK_CLICKED,
  112.             ewl_paned_test_cb_clicked, "HShrink | VFill");
  113.     ewl_widget_show(o);
  114.  
  115.     o = ewl_button_new();
  116.     ewl_button_label_set(EWL_BUTTON(o), "shrink");
  117.     ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_SHRINK);
  118.     ewl_container_child_append(EWL_CONTAINER(pane2), o);
  119.     ewl_callback_append(o, EWL_CALLBACK_CLICKED,
  120.             ewl_paned_test_cb_clicked, "Shrink");
  121.     ewl_widget_show(o);
  122.  
  123.     pane3 = ewl_hpaned_new();
  124.     ewl_container_child_append(EWL_CONTAINER(pane1), pane3);
  125.     ewl_widget_show(pane3);
  126.  
  127.     o = ewl_button_new();
  128.     ewl_button_label_set(EWL_BUTTON(o), "Left Top");
  129.     ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_NONE);
  130.     ewl_object_alignment_set(EWL_OBJECT(o), 
  131.                 EWL_FLAG_ALIGN_LEFT | EWL_FLAG_ALIGN_TOP);
  132.     ewl_container_child_append(EWL_CONTAINER(pane3), o);
  133.     ewl_callback_append(o, EWL_CALLBACK_CLICKED,
  134.             ewl_paned_test_cb_clicked, "Left Top");
  135.     ewl_widget_show(o);
  136.  
  137.     o = ewl_button_new();
  138.     ewl_button_label_set(EWL_BUTTON(o), "Center");
  139.     ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_NONE);
  140.     ewl_object_alignment_set(EWL_OBJECT(o), EWL_FLAG_ALIGN_CENTER);
  141.     ewl_container_child_append(EWL_CONTAINER(pane3), o);
  142.     ewl_callback_append(o, EWL_CALLBACK_CLICKED,
  143.             ewl_paned_test_cb_clicked, "Center");
  144.     ewl_widget_show(o);
  145.  
  146.     o = ewl_button_new();
  147.     ewl_button_label_set(EWL_BUTTON(o), "Right Bottom");
  148.     ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_NONE);
  149.     ewl_object_alignment_set(EWL_OBJECT(o), 
  150.             EWL_FLAG_ALIGN_RIGHT | EWL_FLAG_ALIGN_BOTTOM);
  151.     ewl_container_child_append(EWL_CONTAINER(pane3), o);
  152.     ewl_callback_append(o, EWL_CALLBACK_CLICKED,
  153.             ewl_paned_test_cb_clicked, "Right Bottom");
  154.     ewl_widget_show(o);
  155.  
  156.     box = ewl_hbox_new();
  157.     ewl_container_child_append(EWL_CONTAINER(pane1), box);
  158.     ewl_object_fill_policy_set(EWL_OBJECT(box), 
  159.                 EWL_FLAG_FILL_HFILL | EWL_FLAG_FILL_VSHRINK);
  160.     ewl_widget_show(box);
  161.  
  162.     o = ewl_button_new();
  163.     ewl_button_label_set(EWL_BUTTON(o), "Add to top pane");
  164.     ewl_callback_append(o, EWL_CALLBACK_CLICKED, ewl_paned_test_cb_add, pane2);
  165.     ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_SHRINK);
  166.     ewl_container_child_append(EWL_CONTAINER(box), o);
  167.     ewl_widget_show(o);
  168.  
  169.     o = ewl_button_new();
  170.     ewl_button_label_set(EWL_BUTTON(o), "Add to bottom pane");
  171.     ewl_callback_append(o, EWL_CALLBACK_CLICKED, ewl_paned_test_cb_add, pane3);
  172.     ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_SHRINK);
  173.     ewl_container_child_append(EWL_CONTAINER(box), o);
  174.     ewl_widget_show(o);
  175. }
  176.  
  177.  
  178.